import type {
  AssociationClassByTypeRes,
  AssociationNumberRes,
  HonorYardRes,
  IntegralTrendRes,
  LeaderBoardTableReq,
  OrgUseInfoRes,
  SmLeaderBoardTableRes,
  UseInfoAllByTypeRes,
  UseInfoAllRes,
} from './model';

import { requestClient } from '#/api/request';

enum Api {
  getAssociationClassByType = '/smallProgram/AssociationClassByType',
  getAssociationNumber = '/smallProgram/AssociationNumber',
  getHonorYard = '/smallProgram/HonorYard',
  getIntegralTrend = '/smallProgram/integralTrend',
  getLeaderBoardTable = '/smallProgram/leaderBoardTable',
  getOrgUseInfo = '/smallProgram/useOrg',
  getUseInfoAll = '/smallProgram/allUse',
  getUseInfoAllByType = '/smallProgram/useInfo',
}

/**
 * 各协会使用情况接口
 * @returns
 */
export function getOrgUseInfo() {
  return requestClient.get<OrgUseInfoRes>(Api.getOrgUseInfo);
}

/**
 * 积分趋势图
 */
export function getIntegralTrend(orgId: string) {
  return requestClient.get<IntegralTrendRes>(
    `${Api.getIntegralTrend}/${orgId}`,
  );
}

/**
 * 总平台使用情况全部
 */
export function getUseInfoAll() {
  return requestClient.get<UseInfoAllRes>(Api.getUseInfoAll);
}

/**
 * 根据type获取平台使用数据
 */
export function getUseInfoAllByType(type: string) {
  return requestClient.get<UseInfoAllByTypeRes>(
    `${Api.getUseInfoAllByType}/${type}`,
  );
}

/**
 * 根据type查询积分排行榜数据 
 */
export function getLeaderBoardTable(req: LeaderBoardTableReq) {
  return requestClient.post<SmLeaderBoardTableRes>(
    Api.getLeaderBoardTable,
    req,
  );
}

/**
 * 根据类型type查询协会分类下活动数量
 * type 1为总 2为各组织
 */
export function getAssociationClassByType(type: string) {
  return requestClient.get<AssociationClassByTypeRes>(
    `${Api.getAssociationClassByType}/${type}`,
  );
}

/**
 * 荣誉园地 展示各个二级组织下的荣誉数量
 */
export function getHonorYard() {
  return requestClient.get<HonorYardRes>(Api.getHonorYard);
}

/**
 * 协会数量 展示各个二级组织下的协会数量
 */
export function getAssociationNumber() {
  return requestClient.get<AssociationNumberRes>(Api.getAssociationNumber);
}
